package com.example.demo.schedule;

import com.example.demo.config.ScheduleProperties;
import com.example.demo.service.ScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class ScheduledTaskService {

    @Autowired
    private ScheduleProperties scheduleProperties;

    @Autowired
    private ScheduleService scheduleService;

    // 每2分钟执行一次
    @Scheduled(initialDelay = 1000,fixedDelay = 30000)
    public void executeTask() {
        System.out.println("定时任务执行：" + new Date());
        // 在这里添加你的业务逻辑代码
//        scheduleService.init();
        scheduleService.executeTask();
    }
}
